<template>
	<div id="app">
		<div id="set_data">
			<div class="fill_word">
				<ul>
					<li>
						<p>新密码</p>
						<div class="am-form-group">
							<input type="password" id="password" v-model="fd.password" placeholder="请输入新密码"
								onblur="validate_password(this.value)" />
						</div>
						<div class="clear"></div>
					</li>
					<li>
						<p>确认密码</p>
						<div class="am-form-group">
							<input type="password" id="password2" v-model="fd.password2" placeholder="请再次输入新密码"
								onblur="validate_password2(this.value)" />
						</div>
						<div class="clear"></div>
					</li>
				</ul>
				<div align="center" id="test_pw"></div>
				<div align="center" id="is_test_pw"></div>
				<input type="submit" class="yes" @click="submit()" value="确定"
					style="background-color: #61ac85;border: 1px solid #579572;" />
			</div>
		</div>
	</div>
</template>

<script>
	import config from '@/config'
	export default {
		data() {
			return {
				uni,
				fd: {
					name: '',
					password: "",
					password2: ""
				}
			}
		},
		onLoad(option) {
			if (option.name) {
				this.$set(this.fd, 'name', option.name);
			}
		},
		methods: {
			submit: function() {
				uni.request({
					url: `${config.baseUrl}/modify`,
					method: 'POST',
					data: this.fd,
					success(r) {
						if (r.data.succ) {
							uni.navigateTo({
								url: 'login'
							})
						}
					},
					complete(res){
						if(res.data && res.data.msg){
							uni.showToast({
								icon:'none',
								title:res.data.msg
							})
						}
					},
				})
			},
		}
	}
</script>

<style>
</style>
